package com.stevenmoon.csdnplus.logic;

import com.google.gson.reflect.TypeToken;
import com.stevenmoon.csdnplus.app.Constants;
import com.stevenmoon.csdnplus.bean.AccountBean;
import com.stevenmoon.csdnplus.bean.LoginReqBean;
import com.stevenmoon.csdnplus.bean.ResponseResultBean;
import com.stevenmoon.csdnplus.net.RequestParams;
import com.stevenmoon.csdnplus.net.RxNet;
import com.stevenmoon.csdnplus.util.GsonUtil;
import com.stevenmoon.csdnplus.util.SecurityUtil;

import rx.Observable;

/**
 * Created by WangJun on 2016/4/7.
 */
public class LoginManager {

    public static Observable<ResponseResultBean<AccountBean>> doLogin(LoginReqBean reqBean){
        reqBean.password = SecurityUtil.DESEncrypt(reqBean.password);
        RequestParams rp = new RequestParams(Constants.CSDNURL.LOGIN, GsonUtil.convertBean2Map(reqBean));
        return RxNet.post(rp,new TypeToken<ResponseResultBean<AccountBean>>(){});
    }

//    public static Observable<AccountBean> doLogin2(LoginReqBean reqBean){
//        reqBean.password = SecurityUtil.DESEncrypt(reqBean.password);
//        RequestParams rp = new RequestParams(Constants.CSDNURL.LOGIN, GsonUtil.convertBean2Map(reqBean));
//        return RxNet.postAndFetchEntity(rp,new TypeToken<ResponseResultBean<AccountBean>>(){});
//    }





}
